/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.stub;

import edu.fpt.entity.BillAll;
import edu.fpt.session.BillAllFacadeLocal;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author TuanAnh
 */
public class BillStub {

    BillAllFacadeLocal bill = lookupBillAllFacadeLocal();
    
    public List<BillAll> getBill(){
        return bill.findAll();
    }
    
    public void insertBill(BillAll bi){
        bill.create(bi);
    }
    
    public void updateBill(BillAll bi){
        bill.edit(bi);
    }
    
    public String getDateCome(String id){
        return bill.getDateCome(id);
    }
    
    public void delete(String customerId){
        BillAll cus = bill.find(customerId);
        bill.remove(cus);
    }

    private BillAllFacadeLocal lookupBillAllFacadeLocal() {
        try {
            Context c = new InitialContext();
            return (BillAllFacadeLocal) c.lookup("java:global/ProjectManagementHotel/ProjectManagementHotel-ejb/BillAllFacade!edu.fpt.session.BillAllFacadeLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
